<template>
  <div class="cart-complete-wrap">
    <div class="cart-complete">
      <h3>✔ 商品已成功加入购物车！</h3>
      <div class="goods">
        <div class="left-good">
          <div class="left-pic">
            <img :src="buyInfo.img">
          </div>
          <div class="right-info">
            <p class="title">{{ buyInfo.name }}</p>
            <p class="attr">描述：{{buyInfo.desc}}</p>
            <p class="attr" v-for="(item, index) in buyInfo.arr" :key="index">{{ item.name }} : {{ item.value }}</p>
            <p class="attr">数量：{{buyInfo.num}}</p>
            <p class="attr">单价：{{buyInfo.price}} * {{buyInfo.num}} = {{buyInfo.price * buyInfo.num}}</p>
          </div>
        </div>
        <div class="right-gocart">
          <!-- $router.back() 返回上一页 -->
          <!-- <a @click="$router.back()" class="sui-btn btn-xlarge">查看商品详情</a> -->
          <router-link :to="`/detail/${buyInfo.id}`" class="sui-btn btn-xlarge">查看商品详情</router-link>
          <router-link :to="{ path: '/shopcart'}" >去购物车结算 </router-link>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    name: 'AddCartSuccess',
    data() {
      return {
        buyInfo: JSON.parse(sessionStorage.getItem('buyInfo')) // 从sessionStorage中获取购物车信息
      }
    },
  }
</script>

<style lang="less" scoped>
  .cart-complete-wrap {
    background-color: #f4f4f4;

    .cart-complete {
      width: 1200px;
      margin: 0 auto;
      padding: 3px;
      border: #dddddd 1px solid;
      border-radius: 5px;

      h3 {
        font-weight: 400;
        font-size: 18px;
        color: #6aaf04;
        padding-top: 15px;
        padding-bottom: 15px;
        margin: 0;

        .icon-pc-right {
          background-color: #fff;
          border: 2px solid #6aaf04;
          padding: 3px;
          margin-right: 8px;
          border-radius: 15px;
        }
      }

      .goods {
        overflow: hidden;
        padding: 10px 0;
        display: flex;
        flex-direction: column;
        .left-good {
          display: flex;
          align-items: center;

          .left-pic {
            border: 1px solid #dfdfdf;
            width: 100px;

            img {
              width: 100%;
              height: 100%;
              transition: all 400ms ease;

              &:hover {
                transform: scale(1.3);
              }
            }
          }

          .right-info {
            color: #053bdd;
            margin: 10px;

            .title {
              width: 100%;
              line-height: 28px;
              overflow: hidden;
              text-overflow: ellipsis;
              white-space: nowrap;
              font-size: 16px;
            }

            .attr {
              color: #5b5b5b;
              margin: 5px 0;
            }
          }
        }

        .right-gocart {
          margin: 20px 10px;
          // height: 50px;

          a {
            padding: 7px 36px;
            font-size: 15px;
            // line-height: 22px;
            color: #ededed;
            background-color: #ed7676;
            text-decoration: none;
            box-sizing: border-box;
            border: 1px solid #e1e1e1;
          }

          a:hover {
            color: #383636;
            background-color: #ed7676;
            border: 1px solid #d6d6d6;
          }

          a:active {
            background-color: #e1e1e1;
            border: 1px solid #d5d5d5;
          }

          .btn-danger {
            background-color: #e1251b;
            color: #fff;
          }

          .btn-danger:hover {
            background-color: #e1251b;
          }
        }

      }
    }
  }
</style>